<!DOCTYPE html>
<html>
<head>
	<title>innerText兼容</title>
</head>
<body>
	<div>
		<p>niaho</p>
	</div>
<script type="text/javascript">
	
var div = document.getElementsByTagName('div')[0];
var text = getInnerText(div);
console.log(text);

// innerText兼容处理
function getInnerText(element) {
	var text = null;
	if(text = element.innerText) {
		return text;
	} else {
		text = element.textContent.trim();
		return text;
	}
}

</script>
</body>
</html>